package javabase.concurrent;

public class SimpleTimer {

    private static int count = 0;

    /**
     * 使用sleep实现简易计时器
     * @param args
     */
    public static void main(String[] args) {
        count = 60;
        int remaining;
        while (true) {
            remaining = countDown();
            if (remaining == 0) {
                break;
            } else {
                System.out.println("remaining " + count + " seconds(s)");
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("done");
    }

    private static int countDown() {
        return count--;
    }

}
